<%@ taglib prefix="p" uri="/WEB-INF/tld/privilege.tld" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%     
	String path = request.getContextPath();     
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";     
%> 
<%response.setHeader("cache-control","public"); %>
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title>bug列表</title>
  <base href="<%=basePath%>"/>
  <%@ include file="../../list_include.jsp"%>
  <script language="JavaScript" type="text/javascript" src="<%=basePath%>js/my97/WdatePicker.js" defer="defer"></script>  
  <style type="text/css"> 
	fieldset,table,tr,td {margin:0; padding:0;}
	td {padding:0 5px 0 10px;}
	form label {font-weight:bold;}
	#bugTable {margin:5px 0;}
  </style>

  <script type="text/javascript">
	$(document).ready(function() { 
       	$("#bugTable").tablesorter({theme:'green', widgets:['zebra', "resizable"]});
       	
       	$("#btn_pageUp").click(function(){
			var curPage = $("#curPage").val();
			$("#curPage").val(parseInt(curPage) - 1);
			$("#bugForm").submit();
       	});
       	
       	$("#btn_pageDown").click(function(){
       		var curPage = $("#curPage").val();
			$("#curPage").val(parseInt(curPage) + 1);
			$("#bugForm").submit();
       	});

        $("#btn_insert").click(function(){
            var queryString = $("#bugForm").formSerialize();
            queryString = encodeURIComponent(queryString);
            location.href = "<%=basePath%>soft/bug/insert.do?projectId="+$("#projectId").val()+ "&qs=" + queryString;
        });
        
        $("#btn_search").click(function(){
            $("#curPage").val(1);
            $("#bugForm").submit();
        });

        $("#btn_change").click(function(){
            var page = parseInt($("#selectPage").val());
            var curPage = parseInt($("#curPage").val());
            if(curPage == page) return;
            $("#curPage").val(parseInt(page));
            $("#bugForm").submit();
        });
	});  
	
	function edit(id) {
        var queryString = $("#bugForm").formSerialize();
        queryString = encodeURIComponent(queryString);
        location.href = "<%=basePath%>soft/bug/edit.do?id=" + id + "&qs=" + queryString+ "&projectId="+$("#projectId").val();
	}
	function view(id) {
        var queryString = $("#bugForm").formSerialize();
        queryString = encodeURIComponent(queryString);
        location.href = "<%=basePath%>soft/bug/view.do?id=" + id + "&qs=" + queryString+ "&projectId="+$("#projectId").val();
	}
	function comment(id) {
	    var queryString = $("#bugForm").formSerialize();
        queryString = encodeURIComponent(queryString);
        location.href = "<%=basePath%>soft/bug/bugcomment.do?bugId=" + id + "&qs=" + queryString+ "&projectId="+$("#projectId").val();
	}	
	function del(id) {
		if(confirm("确定删除该对象？") != 1) return;
		$.get("soft/bug/delete.do", {id:id}, function(data) {
			var result = $.parseJSON(data);
			if(result.code == 1) {
				alert("删除成功!");
				$("#btn_search").click();
			} else {
				alert(result.msg);
			}
		});
	}
  </script>
 </head>
 <body>
  <div>
    <fieldset>
      <legend>查询条件：</legend>
      <form id="bugForm" method="post" action="soft/bug/list.do">
        <table>
	        <tr>
				<td ><label for="bugLevel">级别：</label></td>
				<td>
		             <select name="bugLevel" id="bugLevel" style="width:130px;">
						<option value="">--选择级别--</option>
						<c:forEach items="${bugLevelList}" var="bl">
					      <option value="${bl.value}" <c:if test="${bl.value == bugLevel}">selected</c:if> > ${bl.name}</option>
						</c:forEach>
					 </select>
				</td>
		        <td><label for="status">状态：</label></td>
	            <td>
		             <select name="status" id="status" style="width:130px;" >
			              <option value="">--选择状态--</option>
			              <c:if test="${!userCondition}">     <!-- 开发人员 -->
								<option value="fix"   <c:if test="${'fix' == status}">selected</c:if>>修复</option>
								<option value="open"  <c:if test="${'open' == status}">selected</c:if>>打开</option>
								<option value="close" <c:if test="${'close' == status}">selected</c:if>>关闭</option>
						        <option value="reopen" <c:if test="${'reopen' == status}">selected</c:if>>重启</option>
						  </c:if>
						  <c:if test="${userCondition}">     <!-- 开发人员 -->
					            <c:forEach items="${bugStatusList}" var="bs">
							        <option value="${bs.value}" <c:if test="${bs.value == status}">selected</c:if>> ${bs.name}</option>
								</c:forEach>
						  </c:if>
					 </select>
				</td>
				<c:if test="${userCondition}">
				    <td><label for="expurgator">人员：</label></td>
					<td>
					    <select name="expurgator" id="expurgator" style="width:130px;" >
					     <option value="" selected="selected">选择人员</option>
					        <c:forEach items="${userList}" var="u" >
					            <option value="${u.enname}" <c:if test="${u.enname == expurgator}">selected</c:if>><c:out value="${u.cnname}"/></option>
					        </c:forEach>
						</select>
					</td>
				</c:if>
				<td><label for="projectId">项目：</label></td>
				<td>
				    <select name="projectId" id="projectId" style="width:130px;" >
				     <c:forEach items="${projectList}" var="p" >
				            <option value="${p.id}" <c:if test="${p.id == currProject.id}">selected</c:if>><c:out value="${p.name}"/></option>
				     </c:forEach>
					</select>
				</td>
				<td><input type="button" id="btn_search" name="btn_search" value="查询" style="width: 80px;" /></td>
			</tr>
        </table>
        <input type="hidden" name="curPage" id="curPage" value="${curPage}" />
        <input type="hidden" name="totalPage" id="totalPage" value="${totalPage}" />
      </form>
    </fieldset>
  </div>
  
  <div>
  	<table id="bugTable" class="tablesorter">
	  <thead> 
	    <tr> 
          <th width="45%">摘要</th>
		  <th>所属模块</th>
		  <th>填写人</th>
		  <th>修订人员</th>
		  <th>状态</th>
		  <th>级别</th>
		  <th>创建时间</th>
		  <th>操作</th>
 	    </tr> 
	  </thead>
	  <tbody>
	  	<c:forEach items="${bugList}" var="bug" varStatus="status">
 	        <tr align="left">
		        <c:if test="${bug.isAttr==1}">
			       <td>${bug.title} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="<%=basePath%>/images/file.jpg"></img></td>
			    </c:if>
			    <c:if test="${bug.isAttr==0}">
			        <td>${bug.title} </td>
			    </c:if>
				<td>
				 <c:forEach items="${moduleList}" var="m" >
		            <c:if test="${bug.moduleId == m.id}">
		               ${m.name}
                    </c:if>
				 </c:forEach>
				</td>
				<td>${bug.subCnname}</td>
				<td>${bug.expurgatorCn}</td>
				<td>
					<c:forEach items="${bugStatusList}" var="bs">
				        <c:if test="${bug.status == bs.value}">
				           ${bs.name}
				        </c:if>
					</c:forEach>
				</td>
				<td>
					<c:forEach items="${bugLevelList}" var="bl">
				        <c:if test="${bug.bugLevel == bl.value}">
				           ${bl.name}
				        </c:if>
					</c:forEach>
				</td>
				<td>
				   <fmt:formatDate value="${bug.createTime}" type="both" dateStyle="medium" timeStyle="medium" />
				</td>
				<td align="left">
				    <p:chkPri actionUrl="soft/bug/view.do"><a href=# onclick="javascript:view('${bug.id}'); return false;">查看</a></p:chkPri>
				    <c:if test="${bug.status!='close'}">
					 <p:chkPri actionUrl="soft/bug/edit.do"><a href=# onclick="javascript:edit('${bug.id}'); return false;">修改</a></p:chkPri>
					</c:if>
					<p:chkPri actionUrl="soft/bug/bugcomment.do"><a href=# onclick="javascript:comment('${bug.id}'); return false;">评论</a></p:chkPri>
				</td>
			</tr>
	  	</c:forEach>
	  </tbody>
  	</table>
  </div>
  <div>
      <div style="float:left;">
        <p:chkPri actionUrl="soft/bug/insert.do"><input id="btn_insert" type="button" value="新增" /></p:chkPri>
      </div>
      <div style="text-align:right;">
        <c:if test="${curPage <= 1}"><input type="button" disabled="disabled" id="btn_pageUp" value="上一页"/></c:if>
        <c:if test="${curPage > 1}"><input type="button" id="btn_pageUp" value="上一页"/></c:if>
        <c:if test="${curPage >= totalPage}"><input type="button" id="btn_pageDown" disabled="disabled" value="下一页"/></c:if>
        <c:if test="${curPage < totalPage}"><input type="button" id="btn_pageDown" value="下一页"/></c:if>
                     共${totalPage}页/共${totalRecords}条
        <select id="selectPage" style="width: auto;">
            <c:forEach var="i" begin="1" end="${totalPage}">
                <option id="${i}" <c:if test="${i == curPage}">selected="selected"</c:if>>${i}</option>
            </c:forEach>
        </select>
        <input id="btn_change" type="button" value="转至" />
      </div>
  </div>
 </body>
</html>

